package client.service;

import java.util.ArrayList;
import java.util.List;

import org.json.JSONArray;
import org.json.JSONObject;

import client.io.ClientIO;
import domain.action.Action;
import domain.doctor.Doctor;
import domain.nurse.Nurse;
import domain.session.Request;
import domain.session.Response;

public class NurseService {

	public static List<Nurse> getAllNurses() {
		JSONObject requestJson = new JSONObject();
		ClientIO.sendRequest(new Request(Action.GET_ALL_NURSES, requestJson));

		Response response = ClientIO.getResponse();
		JSONObject responseJson = response.getResponse();
		JSONArray nurseArray = responseJson.getJSONArray("nurses");
		
		List<Nurse> nurses = new ArrayList<Nurse>();
		
		for (int i = 0; i < nurseArray.length(); i++) {
			nurses.add(new Nurse(nurseArray.getJSONObject(i)));
		}
		
		return nurses;
	}

}
